/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.web.service;

import java.util.List;

import com.jeeplus.common.config.Global;
import com.jeeplus.common.utils.FileUtils;
import com.jeeplus.core.qr.ImgQrTool;
import com.jeeplus.modules.monitor.utils.Achieve;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.web.entity.YjEquipment;
import com.jeeplus.modules.web.mapper.YjEquipmentMapper;

/**
 * 设备信息Service
 * @author rongjie
 * @version 2017-08-30
 */
@Service
@Transactional(readOnly = true)
public class YjEquipmentService extends CrudService<YjEquipmentMapper, YjEquipment> {

	public YjEquipment get(String id) {
		return super.get(id);
	}

	public List<YjEquipment> findList(YjEquipment yjEquipment) {
		return super.findList(yjEquipment);
	}

	public Page<YjEquipment> findPage(Page<YjEquipment> page, YjEquipment yjEquipment) {
		return super.findPage(page, yjEquipment);
	}

	@Transactional(readOnly = false)
	public void save(YjEquipment yjEquipment) {
		super.save(yjEquipment);
	}

	@Transactional(readOnly = false)
	public void delete(YjEquipment yjEquipment) {
		super.delete(yjEquipment);
	}
	@Transactional(readOnly = false)
	public void updateMaintenance(String number, Integer maintenance) {
		mapper.updateMaintenance(number,maintenance*60);
	}

	public String saveQrCode(String number) {
		String uploadSysUrl = Global.getConfig("FILE");
		String fi=Achieve.getUUIDString()+".png";
		String path = uploadSysUrl+fi;
		FileUtils.createDirectory(uploadSysUrl);
		ImgQrTool.createSimpleQr(Global.getConfig("qrurl")+"?device_id="+number,300,300,path);
		return Global.getConfig("url")+"/image/"+fi;
	}
}
